import torch
from torch import nn
import torch.nn.functional as F
import math

weight = nn.Parameter(torch.Tensor(2, 5))


def reset_parameters(weight):
    bias = torch.FloatTensor([5])
    # bias = None
    n = 3
    nn.init.normal_(weight, std=0.01)
    if bias is not None:
        fan_in, _ = nn.init._calculate_fan_in_and_fan_out(weight)
        bound = 1 / math.sqrt(fan_in)
        nn.init.uniform_(bias, -bound, bound)
    return weight


reset_parameters(weight)
filter = F.softmax(weight, dim=1)
print("创建卷积核", filter)
print(filter[0].sum())
print(filter[1].sum())

# sp_adj = torch.sparse_coo_tensor([[1, 1, 1, 2, 4, 4]], [2, 4, 6, 9, 1, 2], (3,))
# print(sp_adj)
# a = sp_adj.coalesce()
# print(a)
total_edge_index = torch.randn(2, 5)
edge_index = torch.randn(2, 5)
print(torch.cat((total_edge_index, edge_index), dim=1).shape)